from typing import Tuple
import typing as tp
import matplotlib.pyplot as plt
import pandas as pd


def line_point_plot(df: pd.DataFrame, 
                    col: str, 
                    idx: pd.Index, 
                    start_iloc: int = 1000,
                    name: str = "marker",
                    figsize: Tuple[int, int] = (18, 10),
                    show: bool = True):
    temp = pd.concat([df[col], df.loc[idx, col]], axis=1)
    temp.columns = [col, name]
    temp=temp.reset_index(drop=True)
    fig, ax = plt.subplots(figsize=figsize)
    if start_iloc > 0:
        temp = temp.iloc[-start_iloc:]
    temp[col].plot(ax=ax)
    temp["marker"].plot(ax=ax, c="red", marker="o", linewidth=0, markersize=5)
    if show:
        plt.show()
        
        
def plot_net_value(close: pd.Series,
                   ret: pd.Series,
                   pred_side: pd.Series,
                   rest_iloc: int,
                   figsize: Tuple[float, float] = (18, 10)):
    exp_ret = pred_side * ret
    comp = pd.concat([close, exp_ret], axis=1)
    comp = tp.cast(pd.DataFrame, comp)
    comp = comp.dropna()
    # comp = comp.rename(columns={0:"exp_ret"})
    comp.columns = ["close", "exp_ret"]
    comp = comp.iloc[-rest_iloc:]
    comp["base"] = comp["close"] / comp["close"].iloc[0]
    comp["net"] = (comp["exp_ret"] + 1).cumprod()
    comp[["base", "net"]].plot(figsize=figsize)
    plt.show()